<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!--
  Copyright 2013, 2015 IBM Corp.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<head>
    <title>{{ page.title }}</title>
    <link rel="icon" type="image/png" href="{{ page.favicon }}">
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="vendor/jquery/css/smoothness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="vendor/vendor.css">
    <link rel="stylesheet" href="red/style.min.css">
    <link rel="stylesheet" type="text/css" href="vendor/rappid/rappid.min.css" />
    {{#page.css}}
    <link rel="stylesheet" href="{{.}}">
    {{/page.css}}
    <link rel="stylesheet" href="vendor/lmz.css">
</head>
<body spellcheck="false">
<div id="header">
    <span class="logo">{{#header.url}}<a href="{{.}}">{{/header.url}}{{#header.image}}<img src="{{.}}">{{/header.image}}
        <span>{{ header.title }}</span>{{#header.url}}</a>{{/header.url}}</span>
    <ul class="header-toolbar hide">
        <li><a id="btn-sidemenu" class="button" data-toggle="dropdown" href="#"><i class="fa fa-bars"></i></a></li>
    </ul>
    <a class="btn" id="run">run</a>
</div>
<div id="state_machine">
    <a class="pullbtn" id="toggle_tool" href="#"><i class="fa fa-toggle-down"></i> </a>
</div>
<div id="main-container" class="sidebar-closed hide">
    <div id="palette">
        <img src="red/images/spin.svg" class="palette-spinner hide"/>

        <div id="palette-search">
            <i class="fa fa-search"></i><input id="palette-search-input" type="text"
                                               data-i18n="[placeholder]palette.filter"><a href="#"
                                                                                          id="palette-search-clear"><i
                class="fa fa-times"></i></a></input>
        </div>
        <div id="palette-container" class="palette-scroll">

        </div>
        <div id="palette-footer">
            <a class="palette-button" id="palette-collapse-all" href="#"><i class="fa fa-angle-double-up"></i></a>
            <a class="palette-button" id="palette-expand-all" href="#"><i class="fa fa-angle-double-down"></i></a>
        </div>

    </div>
    <!-- /palette -->

    <div id="workspace">
        <ul id="workspace-tabs"></ul>
        <div id="workspace-add-tab"><a id="btn-workspace-add-tab" href="#"><i class="fa fa-plus"></i></a></div>
        <div id="chart"></div>
        <div id="workspace-toolbar"></div>
        <div id="workspace-footer">
            <a class="workspace-footer-button" id="btn-zoom-out" href="#"><i class="fa fa-minus"></i></a>
            <a class="workspace-footer-button" id="btn-zoom-zero" href="#"><i class="fa fa-circle-o"></i></a>
            <a class="workspace-footer-button" id="btn-zoom-in" href="#"><i class="fa fa-plus"></i></a>
        </div>
    </div>
    <div id="sidebar">
        <ul id="sidebar-tabs"></ul>
        <div id="sidebar-content"></div>
        <div id="sidebar-footer"></div>
    </div>

    <div id="sidebar-separator"></div>

</div>

<div id="notifications"></div>
<div id="dropTarget">
    <div data-i18n="[append]workspace.dropFlowHere"><br/><i class="fa fa-download"></i></div>
</div>

<div id="dialog" class="hide">
    <form id="dialog-form" class="form-horizontal"></form>
</div>
<div id="node-config-dialog" class="hide">
    <form id="dialog-config-form" class="form-horizontal">
        <div id="node-config-dialog-edit-form"></div>
        <!--<div id="node-config-dialog-toolbar" class="form-row"><label><span>Node scope</span></label><select id="node-config-dialog-scope"></select></div>-->
    </form>
</div>
<div id="subflow-dialog" class="hide">
    <form class="form-horizontal">
        <div class="form-row">
            <label for="subflow-input-name" data-i18n="common.label.name"></label><input type="text"
                                                                                         id="subflow-input-name">
        </div>
        <div class="form-row" style="margin-bottom: 0px;">
            <label for="subflow-input-info" data-i18n="subflow.info"></label>
            <a href="https://help.github.com/articles/markdown-basics/" style="font-size: 0.8em; float: right;"
               data-i18n="[html]subflow.format"></a>
        </div>
        <div class="form-row node-text-editor-row">
            <div style="height: 250px;" class="node-text-editor" id="subflow-input-info-editor"></div>
        </div>
        <div class="form-row form-tips" id="subflow-dialog-user-count"></div>
    </form>
</div>

<div id="node-dialog-confirm-deploy" class="hide">
    <form class="form-horizontal">
        <div id="node-dialog-confirm-deploy-config" style="text-align: left; padding-top: 30px;"
             data-i18n="[prepend]deploy.confirm.improperlyConfigured;[append]deploy.confirm.confirm">
            <ul style="font-size: 0.9em; width: 400px; margin: 10px auto; text-align: left;"
                id="node-dialog-confirm-deploy-invalid-list"></ul>
        </div>
        <div id="node-dialog-confirm-deploy-unknown" style="text-align: left; padding-top: 10px;"
             data-i18n="[prepend]deploy.confirm.unknown;[append]deploy.confirm.confirm">
            <ul style="font-size: 0.9em; width: 400px; margin: 10px auto; text-align: left;"
                id="node-dialog-confirm-deploy-unknown-list"></ul>
        </div>
        <div id="node-dialog-confirm-deploy-unused" style="text-align: left; padding-top: 10px;"
             data-i18n="[prepend]deploy.confirm.unusedConfig;[append]deploy.confirm.confirm">
            <ul style="font-size: 0.9em; width: 400px; margin: 10px auto; text-align: left;"
                id="node-dialog-confirm-deploy-unused-list"></ul>
        </div>
    </form>
</div>

<div id="node-dialog-library-save-confirm" class="hide">
    <form class="form-horizontal">
        <div style="text-align: center; padding-top: 30px;" id="node-dialog-library-save-content">
        </div>
    </form>
</div>

<div id="node-dialog-library-save" class="hide">
    <form class="form-horizontal">
        <div class="form-row">
            <label for="node-dialog-library-save-folder" data-i18n="[append]library.folder"><i
                    class="fa fa-folder-open"></i> </label>
            <input type="text" id="node-dialog-library-save-folder" data-i18n="[placeholder]library.folderPlaceholder">
        </div>
        <div class="form-row">
            <label for="node-dialog-library-save-filename" data-i18n="[append]library.filename"><i
                    class="fa fa-file"></i> </label>
            <input type="text" id="node-dialog-library-save-filename"
                   data-i18n="[placeholder]library.filenamePlaceholder">
        </div>
    </form>
</div>

<div id="node-dialog-library-lookup" class="hide">
    <form class="form-horizontal">
        <div class="form-row">
            <ul id="node-dialog-library-breadcrumbs" class="breadcrumb">
                <li class="active"><a href="#" data-i18n="[append]library.breadcrumb"></a></li>
            </ul>
        </div>
        <div class="form-row">
            <div style="vertical-align: top; display: inline-block; height: 100%; width: 30%; padding-right: 20px;">
                <div id="node-select-library"
                     style="border: 1px solid #999; width: 100%; height: 100%; overflow:scroll;">
                    <ul></ul>
                </div>
            </div>
            <div style="vertical-align: top; display: inline-block;width: 65%; height: 100%;">
                <div style="height: 100%; width: 95%;" class="node-text-editor" id="node-select-library-text"></div>
            </div>
        </div>
    </form>
</div>
<div id="node-dialog-rename-workspace" class="hide">
    <form class="form-horizontal">
        <div class="form-row">
            <label for="node-input-workspace-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
            <input type="text" id="node-input-workspace-name">
        </div>
    </form>
</div>
<div id="node-dialog-delete-workspace" class="hide">
    <form class="form-horizontal">
        <div style="text-align: center; padding-top: 30px;" id="node-dialog-delete-workspace-content">
        </div>
    </form>
</div>

<script type="text/x-red" data-template-name="export-library-dialog">
    <div class="form-row">
        <label for="node-input-filename" data-i18n="[append]editor:library.filename"><i class="fa fa-file"></i> </label>
        <input type="text" id="node-input-filename" data-i18n="[placeholder]editor:library.fullFilenamePlaceholder">
    </div>

</script>

<script type="text/x-red" data-template-name="subflow">
    <div class="form-row">
        <label for="node-input-name" data-i18n="[append]editor:common.label.name"><i class="fa fa-tag"></i> </label>
        <input type="text" id="node-input-name">
    </div>

</script>
<script type="text/javascript" src="vendor/statejs/state.js" target="StateJs"></script>
<script src="vendor/jquery/js/jquery-1.11.1.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="vendor/jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="vendor/jquery/js/jquery.ui.touch-punch.min.js"></script>
<script src="vendor/marked/marked.min.js"></script>
<script src="vendor/orion/built-editor.min.js"></script>
<script src="vendor/d3/d3.v3.min.js"></script>
<script src="vendor/i18next/i18next.min.js"></script>


<!--<script src="vendor/vendor.js"></script>-->
<script src="vendor/ace/ace.js"></script>
<script src="vendor/ace/ext-language_tools.js"></script>
<script src="vendor/lodash/lodash.js"></script>
<script src="vendor/backbone/backbone.js"></script>
<script src="vendor/rappid/geometry.js"></script>
<script src="vendor/rappid/vectorizer.js"></script>
<script src="vendor/rappid/joint.js"></script>
<script src="vendor/rappid/joint.dia.graph.js"></script>
<script src="vendor/rappid/joint.dia.cell.js"></script>
<script src="vendor/rappid/joint.dia.CellView.js"></script>
<script src="vendor/rappid/joint.dia.element.js"></script>
<script src="vendor/rappid/joint.dia.ElementView.js"></script>
<script src="vendor/rappid/joint.dia.link.js"></script>
<script src="vendor/rappid/joint.dia.LinkView.js"></script>
<script src="vendor/rappid/joint.dia.paper.js"></script>
<script src="vendor/rappid/joint.dia.GraphCells.js"></script>
<script src="vendor/rappid/joint.dia.CommandManager.js"></script>
<script src="vendor/rappid/joint.dia.Validator.js"></script>


<script src="vendor/rappid/plugins/connectors/joint.connectors.jumpover.js"></script>
<script src="vendor/rappid/plugins/connectors/joint.connectors.normal.js"></script>
<script src="vendor/rappid/plugins/connectors/joint.connectors.rounded.js"></script>
<script src="vendor/rappid/plugins/connectors/joint.connectors.smooth.js"></script>

<script src="vendor/rappid/plugins/routers/joint.routers.manhattan.js"></script>
<script src="vendor/rappid/plugins/routers/joint.routers.metro.js"></script>
<script src="vendor/rappid/plugins/routers/joint.routers.oneSide.js"></script>
<script src="vendor/rappid/plugins/routers/joint.routers.orthogonal.js"></script>

<script src="vendor/rappid/plugins/layout/DirectedGraph/joint.layout.DirectedGraph.js"></script>
<script src="vendor/rappid/plugins/layout/DirectedGraph/joint.layout.ForceDirected.js"></script>
<script src="vendor/rappid/plugins/layout/DirectedGraph/joint.layout.GridLayout.js"></script>
<script src="vendor/rappid/plugins/layout/DirectedGraph/joint.layout.TreeLayout.js"></script>


<script src="vendor/rappid/plugins/joint.shapes.basic.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.chess.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.devs.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.erd.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.fsa.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.logic.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.org.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.pn.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.uml.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.chart.js"></script>
<script src="vendor/rappid/plugins/joint.shapes.bpmn.js"></script>

<script src="vendor/rappid/plugins/myui/joint.shapes.origin.js"></script>

<script src="vendor/rappid/rappid.js"></script>

<script src="vendor/rappid/plugins/ui/joint.ui.PaperScroller.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.SelectionView.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Clipboard.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Halo.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Stencil.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Inspector.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.FreeTransform.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Tooltip.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Snaplines.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.TextEditor.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Dialog.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.FlashMessage.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Lightbox.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.ContextToolbar.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Popup.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.SelectBox.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.ColorPalette.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.SelectButtonGroup.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.Navigator.js"></script>
<script src="vendor/rappid/plugins/ui/joint.ui.TreeLayoutView.js"></script>

<script src="vendor/rappid/plugins/extra/joint.alg.js"></script>
<script src="vendor/rappid/plugins/extra/joint.com.Channel.js"></script>
<script src="vendor/rappid/plugins/extra/joint.storage.js"></script>

<!--script src="{{ asset.red }}"></script-->
<script src="editor/js/main.js"></script>
<script src="editor/js/events.js"></script>
<script src="editor/js/i18n.js"></script>
<script src="editor/js/settings.js"></script>
<script src="editor/js/user.js"></script>
<script src="editor/js/comms.js"></script>
<script src="editor/js/ui/state.js"></script>
<script src="editor/js/nodes.js"></script>
<script src="editor/js/history.js"></script>
<script src="editor/js/validators.js"></script>
<script src="editor/js/ui/deploy.js"></script>
<script src="editor/js/ui/menu.js"></script>
<script src="editor/js/ui/keyboard.js"></script>
<script src="editor/js/ui/tabs.js"></script>
<script src="editor/js/ui/popover.js"></script>
<script src="editor/js/ui/workspaces.js"></script>
<!--<script src="editor/js/ui/view.js"></script>-->
<script src="editor/js/ui/Paper.js"></script>
<script src="editor/js/ui/myView.js"></script>
<script src="editor/js/ui/sidebar.js"></script>
<script src="editor/js/ui/palette.js"></script>
<script src="editor/js/ui/tab-info.js"></script>
<script src="editor/js/ui/tab-config.js"></script>
<script src="editor/js/ui/editor.js"></script>
<script src="editor/js/ui/clipboard.js"></script>
<script src="editor/js/ui/library.js"></script>
<script src="editor/js/ui/notifications.js"></script>
<script src="editor/js/ui/subflow.js"></script>
<script src="editor/js/ui/touch/radialMenu.js"></script>
<script src="editor/js/machine.js"></script>
<script src="editor/js/test/joint_test.js"></script>

<script>
$.fn.toggler = function(fn, fn2) {
    var args = arguments,
        guid = fn.guid || $.guid++,
        i = 0,
        toggler = function(event) {
            var lastToggle = ($._data(this, "lastToggle" + fn.guid) || 0) % i;
            $._data(this, "lastToggle" + fn.guid, lastToggle + 1);
            event.preventDefault();
            return args[lastToggle].apply(this, arguments) || false;
        };
    toggler.guid = guid;
    while (i < args.length) {
        args[i++].guid = guid;
    }
    return this.click(toggler);
};


$(".ui-draggable").draggable({
    helper: 'clone',
    appendTo: 'body',
    revert: true,
    revertDuration: 50,
    start: function() {
        RED.view.focus();
    }
});

$(document).ready(
    function() {
        $("#run").click(function() {
            RED.machine.run();
            console.log("eval finsh");
        });
    
        $("#toggle_tool").toggler( function() {

            $('#state_machine').animate({
                height: '100px'
            }, 300);
            $('#main-container').animate({
                top: '140px'
            }, 300)
            $("i",this).removeClass("fa-toggle-down").addClass("fa-toggle-up");

        },function() {

            $('#state_machine').animate({
                height: '40px'
            }, 300);
            $('#main-container').animate({
                top: '80px'
            }, 300);
            $("i",this).removeClass("fa-toggle-up").addClass("fa-toggle-down");

        });

    }
);

</script>
</body>
</html>
